use proto_bytes::frame::ToEc;
use utils::ufmt;

use crate::error::AppErr;


mod drain_task;
mod recv_task;
pub mod handler;
pub mod status;
pub mod driver;

#[derive(ufmt::derive::uDebug, Clone, Copy)]
pub enum DropErr {
    Drop1Timeout = 0x11,
    Drop2Timeout = 0x12,
    Drop3Timeout = 0x13,
    FilmDotCup = 0x14,
    FilmTimeout = 0x15,
    CutCupTimeout = 0x16,
    CutCupAlm = 0x17,
    DropEmpty = 0x18,
}

impl ToEc for DropErr {
    fn to_ec(self) -> u8 {
        self as u8
    }
}

impl From<DropErr> for AppErr {
    fn from(value: DropErr) -> Self {
        AppErr::Drop(value)
    }
}

pub unsafe fn init() {
    driver::init();
    recv_task::start();
    drain_task::start();
}

